const express = require("express");
const router = express.Router();
const models = require("../models");
const Op = models.Sequelize.Op; // 模糊查询的时候需要用到

// 获取物资申请记录
router.get("/:id", async function (req, res, next) {
  const where = {}
  where.applyId = {
    [Op.like]: req.params.id,
  };
  const result = await models.GoodsRecord.findAndCountAll({
    where: where,
    include: [
      {
        attributes: ["username", "name", "stuCode", "phone", "role", "gender"],
        model: models.User,
      },
    ],
  });
  res.json({
    code: 200,
    msg: "操作成功",
    data: result.rows
  });
});


module.exports = router;
